package com.ruoyi.redis;


import com.ruoyi.common.core.domain.AjaxResult;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ExceptionHandler;

import static com.ruoyi.common.utils.ip.AddressUtils.log;


public class RateLimitException extends RuntimeException {
    public RateLimitException(String message) {
        super(message);
    }

    public RateLimitException(String message, Throwable cause) {
        super(message, cause);
    }
    @ExceptionHandler(RateLimitException.class)
    public AjaxResult handleRateLimitException(RateLimitException e) {
        log.error(e.getMessage(), e);
        return AjaxResult.error(HttpStatus.TOO_MANY_REQUESTS.value(), e.getMessage());
    }
}
